<%@page import="org.jeecgframework.web.util.StaticValue"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>巡检计划详情</title>
    <t:base type="jquery,easyui,tools,DatePicker"></t:base>
    <script type="text/javascript" src="plug-in/ckfinder/ckfinder.js"></script>
    <script type="text/javascript">
        $(function(){
            if($("select[name='company'] option:selected").val() != ""){
                var companyVal = $("select[name='company'] option:selected").val();
                $.ajax({
                    url : "zyCommonController.do?queryTPServerBusinessr",
                    data : {
                        "orgCode" : companyVal,
                        "contactPosition" : '<%=StaticValue.DIC_CONTACT_POSITION_TP_SERVER_BUSINESSR%>'
                    },
                    cache : false,
                    dataType : 'json',
                    type : 'POST',
                    success : function(data){
                        if(data.success){
                            var obj = data.obj[0];
                            if(obj){
                                setContacter(obj.id, obj.name, obj.cellphone1 + (obj.cellphone2==""?"":("/"+obj.cellphone2)),obj.email);
                            }else{
                                setContacter();
                            }
                        }
                    }
                });
            }
            $("#submitBtn").click(function(){
                $.dialog.confirm("确认保存巡检计划吗？",function(r){
                    if(r){
                        _form.submitForm(false,"zyInspectionPlanController.do?doUpdate");
                    }
                });
            });
            $("select[name='company']").change(function(){
                if($(this,"option:selected").val() != ""){
                    $.ajax({
                        url : "zyCommonController.do?queryTPServerBusinessr",
                        data : {
                            "orgCode" : $(this).val(),
                            "contactPosition" : '<%=StaticValue.DIC_CONTACT_POSITION_TP_SERVER_BUSINESSR%>'
                        },
                        cache : false,
                        dataType : 'json',
                        type : 'POST',
                        success : function(data){
                            if(data.success){
                                var obj = data.obj[0];
                                if(obj){
                                    setContacter(obj.id, obj.name, obj.cellphone1 + (obj.cellphone2==""?"":("/"+obj.cellphone2)),obj.email);
                                }else{
                                    setContacter();
                                }
                            }
                        }
                    });
                }else{
                    setContacter();
                }
            });
            $("#cancelPlan").click(function(){
                createwindow("取消巡检计划","zyInspectionPlanController.do?goCancelIP&id="+$("#id").val(),500,200);
                <%--		$.ajax({--%>
                <%--			url : "zyInspectionPlanController.do?doUpdate",--%>
                <%--			data : {--%>
                <%--				"id" : $("#id").val(),--%>
                <%--				"operationType" : '<%=StaticValue.DIC_PLAN_OPERATION_TYPE_CANCEL%>'--%>
                <%--				},--%>
                <%--			cache : false,--%>
                <%--			dataType : 'json',--%>
                <%--			type : 'POST',--%>
                <%--			success : function(data){--%>
                <%--				subCallback(data);--%>
                <%--			}--%>
                <%--		});--%>
            });
            $("#addChildPlan").click(function(){
                var parentId = '${zyIP.zyIp.id}';
                if(parentId == undefined || parentId == ''){
                    addOneTab("新建巡检计划","zyInspectionPlanController.do?goBatchGeneratePlan&esLength=1&equipmentIds=${zyES.id}&parentId=${zyIP.id}");
                }else{
                    tip("当前巡检计划不能创建子单");
                }
            });
            var ipState = '${zyIP.state}';
            var btnSaveRules = '${btnSaveRules}';
            if(ipState != btnSaveRules){
                $("select[name='company']").after("<span>"+$("select[name='company'] option:selected").text() +"</span>").remove();
                $("select[name='lightPath']").after("<span>"+$("select[name='lightPath'] option:selected").text() +"</span>").remove();
                $("select[name='ipMonth']").after("<span>"+$("select[name='ipMonth'] option:selected").text()  +"</span>").remove();
                $("textarea[name='remarks']").attr("readonly","readonly").css({"border":"none","resize":"none"});
            }
        });
        function setContacter(id,name,cellPhone,email){
            if(id == undefined || id == ""){
                $("#contacterId").val("");
                $("#contacterName").val("");
                $("#contacterCellPhone").html("");
                $("#contacterEmail").html("");
            }else{
                $("#contacterId").val(id);
                $("#contacterName").val(name);
                $("#contacterCellPhone").html(cellPhone);
                $("#contacterEmail").html(email);
            }
        }
        function subCallback(data){
            if(data.success){
                window.top.$("#maintabs").tabs({
                    onBeforeClose : function(title,index){
                        try {
                            window.top.$("#maintabs").tabs('select','巡检计划管理');
                            window.top.tip(data.msg);
                            if(top.myTabWin.reloadTable()){
                                top.myTabWin.reloadTable();
                            }
                        } catch (e) {
                        } finally{
                            return true;
                        }
                    }
                });
                window.top.$("#maintabs").tabs('close','巡检计划详情');
            }else{
                tip(data.msg);
            }
        }
    </script>
    <style type="text/css">
        .states{
            min-width: 120px; height: 30px; float: left;line-height: 30px;text-align: center;
        }
        .triangle{
            width: 0; height: 0; border-top: 15px solid transparent; border-left: 15px solid #009DDA; border-bottom: 15px solid transparent; float: left;
        }
        .triangle_1{
            width: 0; height: 0; border-top: 15px solid transparent; border-left: 15px solid #00CC66; border-bottom: 15px solid transparent; float: left;
        }
        .triangle_2{
            width: 0; height: 0; border-top: 15px solid transparent; border-left: 15px solid #E4E4E4; border-bottom: 15px solid transparent; float: left;
        }
        .triangle_c{
            width: 0; height: 0; border-top: 15px solid transparent; border-left: 15px solid white; border-bottom: 15px solid transparent; float: left; background-color: #00CC66;
        }
        .triangle_c_2{
            width: 0; height: 0; border-top: 15px solid transparent; border-left: 15px solid white; border-bottom: 15px solid transparent; float: left; background-color: #E4E4E4;
        }
    </style>
</head>
<body>
<div><span class="navtitle">巡检计划ID:</span><span class="navid">${zyIP.planId }</span></div>
<div style="height: 40px;line-height: 40px;padding-left:20px;">
    <c:forEach var="item" items="${planStateProcessBeans }" varStatus="status">
        <c:if test="${status.first}">
            <div class="states" style="${item.isComplete ? 'background-color: #009DDA;' : 'background-color: #E4E4E4; color : #999999;'}" ><span >${item.stateVal }</span></div>
            <div class="triangle"></div>
        </c:if>
        <c:if test="${!status.first && !status.last }">
            <div class="${item.isComplete ? 'triangle_c' : 'triangle_c_2'}" style="margin-left:10px;"></div>
            <div class="states" style="${item.isComplete ? 'background-color: #00CC66' : 'background-color: #E4E4E4; color : #999999;'}" ><span>${item.stateVal }</span></div>
            <div class="${item.isComplete ? 'triangle_1' : 'triangle_2'}"></div>
        </c:if>
        <c:if test="${status.last}">
            <div class="${item.isComplete ? 'triangle_c' : 'triangle_c_2'}" style="margin-left:10px;"></div>
            <div class="states" style="${item.isComplete ? 'background-color: #00CC66' : 'background-color: #E4E4E4; color : #999999;'}" ><span>${item.stateVal }</span></div>
        </c:if>
    </c:forEach>
</div>
<div style="height: 5px;"></div>
<t:formvalid formid="planDetail" action="zyInspectionPlanController.do?doUpdate" layout="" dialog="false" callback="subCallback">
    <input type="hidden" name="operationType" value="<%=StaticValue.DIC_PLAN_OPERATION_TYPE_UPDATE%>"/>
    <div class="subtitle"><p>巡检计划信息</p>
        <input type="hidden" value="${zyIP.id }" name="id" id="id"/>
        <table class="nobordertable noborder">
            <tr>
                <td class="al_r" width="20%">
                    <label>巡检单位:</label>
                </td>
                <td width="20%">
					<span>
						<select name="company" id="company">
							<c:forEach items="${tsDeparts }" var="depart">
                                <option value="${depart.orgCode }" <c:if test="${depart.orgCode eq zyIP.company }">selected="selected"</c:if> >${depart.shortname }</option>
                            </c:forEach>
						</select>
					</span>
                </td>
                <td class="al_r" width="30%">
                    <label>计划巡检月份:</label>
                </td>
                <td width="30%">
                    <span><t:dictSelect field="ipMonth" typeGroupCode="<%=StaticValue.DIC_IP_MONTH %>" defaultVal="${zyIP.ipMonth }"></t:dictSelect></span>
                </td>
            </tr>
            <tr>
                <td class="al_r">
                    <label>巡检状态:</label>
                </td>
                <td>
                    <span>${zyIP.stateVal }</span>
                </td>
                <td class="al_r">
                    <label>光路要求:</label>
                </td>
                <td>
                    <span><t:dictSelect field="lightPath" typeGroupCode="<%=StaticValue.DIC_LIGHT_PATH %>" defaultVal="${zyIP.lightPath }"></t:dictSelect></span>
                </td>
            </tr>
            <tr>
                <td class="al_r">
                    <label>巡检负责人:</label>
                </td>
                <td>
                    <input name="contacter.id" type="hidden" id="contacterId" />
                    <input name="name" class="inputxt" id="contacterName" readonly="readonly" style="border:none;" datatype="*" nullmsg="请重新选择巡检单位"/>
                </td>
                <td class="al_r">
                    <label>巡检负责人电话:</label>
                </td>
                <td>
                    <span id="contacterCellPhone">${zyIP.contacter.cellphone1 } / ${zyIP.contacter.cellphone2 }</span>
                </td>
            </tr>
            <tr>
                <td class="al_r">
                    <label>巡检负责人邮箱:</label>
                </td>
                <td>
                    <span id="contacterEmail">${zyIP.contacter.email }</span>
                </td>
                <td class="al_r">
                    <label>预约服务期间:</label>
                </td>
                <td>
                    <c:if test="${!empty zyIP.orderBeginTime && !empty zyIP.orderEndTime}">
                        <fmt:formatDate  value="${zyIP.orderBeginTime }" type="both" pattern="yyyy/MM/dd" />~
                        <fmt:formatDate  value="${zyIP.orderEndTime }" type="both" pattern="yyyy/MM/dd" />
                    </c:if>
                    <c:if test="${empty zyIP.orderBeginTime && empty zyIP.orderEndTime}">
                        无
                    </c:if>
                </td>
            </tr>
            <tr>
                <td class="al_r">
                    <label>巡检工程师:</label>
                </td>
                <td>
                    <span>${empty zyIP.engineer.name ? '无' : zyIP.engineer.name}</span>
                </td>
                <td class="al_r">
                    <label>工程师预约上门时间:</label>
                </td>
                <td>
                    <c:if test="${!empty zyIP.engineerOrderTime}">
                        <fmt:formatDate  value="${zyIP.engineerOrderTime }" type="both" pattern="yyyy-MM-dd" />
                    </c:if>
                    <c:if test="${empty zyIP.engineerOrderTime}">
                        无
                    </c:if>
                </td>
            </tr>
            <tr>
                <td class="al_r">
                    <label>巡检工程师电话:</label>
                </td>
                <td>
                    <span>${empty zyIP.engineer.cellphone ? '无' : zyIP.engineer.cellphone}</span>
                </td>
                <td class="al_r">
                    <label>备注:</label>
                </td>
                <td >
                    <span><textarea name="remarks" rows="2" cols="50" maxlength="500" datatype="*1-500">${empty zyIP.remarks ? '无' : zyIP.remarks}</textarea></span>
                </td>
            </tr>
        </table>
    </div>
</t:formvalid>
<br/>
<div class="subtitle">
    <p>设备相关信息</p>
    <table class="nobordertable noborder">
        <tr>
            <td class="al_r" width="20%">
                <label>设备SN:</label>
            </td>
            <td width="20%">
                <span>${zyES.sn }</span>
            </td>
            <td class="al_r" width="30%">
                <label>设备型号:</label>
            </td>
            <td width="30%">
                <c:if test="${not empty zyES.type}">
                    <span>${zyES.type.typeDesc }</span>
                </c:if>
            </td>
        </tr>
        <tr>
            <td class="al_r">
                <label>BP:</label>
            </td>
            <td >
                <span>${zyES.bpNo }</span>
            </td>
            <td class="al_r">
                <label>安装日期:</label>
            </td>
            <td>
                <span><fmt:formatDate  value="${zyES.installDate }" type="both" pattern="yyyy-MM-dd" /></span>
            </td>
        </tr>
        <tr>
            <td class="al_r">
                <label>所属厅:</label>
            </td>
            <td>
                <span>${zyES.house.roomNum }</span>
            </td>
            <td class="al_r">
                <label>保修截止日期:</label>
            </td>
            <td>
                <span><fmt:formatDate  value="${zyES.repairEndDate }" type="both" pattern="yyyy-MM-dd" /></span>
            </td>
        </tr>
        <tr>
            <td class="al_r">
                <label>银幕类型:</label>
            </td>
            <td>
                <span>${screenType }</span>
            </td>
            <td class="al_r">
                <label>银幕增益:</label>
            </td>
            <td>
                <span>${zyES.house.screenPlus }</span>
            </td>
        </tr>
        <tr>
            <td class="al_r">
                <label>宽银幕高:</label>
            </td>
            <td>
                <span>${zyES.house.screenHight }</span>
            </td>
            <td class="al_r">
                <label>宽银幕宽:</label>
            </td>
            <td>
                <span>${zyES.house.screenWidth }</span>
            </td>
        </tr>
        <tr>
            <td class="al_r">
                <label>放映距离:</label>
            </td>
            <td>
                <span>${zyES.house.showKm }</span>
            </td>
            <td class="al_r">
                <label>宽银幕镜头比:</label>
            </td>
            <td>
                <span>${zyES.house.screenLensRatio }</span>
            </td>
        </tr>
        <tr>
            <td class="al_r">
                <label>遮幅镜头比:</label>
            </td>
            <td>
                <span>${zyES.house.curtainLensRatio }</span>
            </td>
            <td class="al_r">
                <label>是否激光改造:</label>
            </td>
            <td>
                <c:if test="${not empty zyES.laserReconstruction}" >
                    <span>${zyES.laserReconstruction eq 1 ? '是' : '否'}</span>
                </c:if>
                <c:if test="${empty zyES.laserReconstruction}" >
                    <span>无</span>
                </c:if>
            </td>
        </tr>
    </table>
</div>
<div class="subtitle">
    <p>所在影院信息</p>
    <table class="nobordertable noborder">
        <tr>
            <td class="al_r" width="20%">
                <label>影院名称:</label>
            </td>
            <td width="20%">
                <span>${zyES.zyCinema.name }</span>
            </td>
            <td class="al_r" width="30%">
                <label>影院地址:</label>
            </td>
            <td width="30%">
                <span>${zyES.zyCinema.address }</span>
            </td>
        </tr>
        <tr>
            <td class="al_r">
                <label>影院所属省市:</label>
            </td>
            <td>
				<span>${zyES.zyCinema.province.TSTerritory.territoryName}
				<c:if test="${!empty zyES.zyCinema.province.TSTerritory.territoryName && !empty zyES.zyCinema.province.territoryName ? ',' : ''}"></c:if>
                    ${zyES.zyCinema.province.territoryName }</span>
            </td>
            <td class="al_r">
                <label>影院巡检联系人:</label>
            </td>
            <td>
                <span>${zyContact.name }  ${zyContact.cellphone1 }</span>
            </td>
        </tr>
        <tr>
            <td class="al_r">
                <label>影院技术主管:</label>
            </td>
            <td>
                <c:if test="${!empty cmContactTechnicalDirector }" ><span>${cmContactTechnicalDirector.name}</span></c:if>
            </td>
            <td class="al_r">
                <label>影院技术主管电话:</label>
            </td>
            <td>
                <c:if test="${!empty cmContactTechnicalDirector }" ><span>${empty cmContactTechnicalDirector.cellphone1 ? cmContactTechnicalDirector.cellphone2 : cmContactTechnicalDirector.cellphone1 }</span></c:if>
            </td>
        </tr>
    </table>
</div>
<div class="subtitle">
    <p>流程流转历史</p>
    <div id="planRecordDiv"></div>
</div>
</body>
<script type="text/javascript">
    $(function(){
        $("#viewIpReport").click(function(){
            viewOrUpdateIReport("view");
        });
        $("#updateIpReport").click(function(){
            viewOrUpdateIReport("update");
        });
        drawPlanRecordTable('${zyIP.id}');
        $("select[name='ipMonth']").on('change',function(){
            console.log("$(this).val()"+$(this).val());
            if(parseInt($(this).val()) < parseInt('${currMonth}')){
                console.log('${currMonth}');
                selectCurrMonth();
                tip("所选月份不应小于当前月,已置为当前月份");
            }
        });
        function selectCurrMonth(){
            $("select[name='ipMonth']").find("option[value='"+'${currMonth}'+"']").attr("selected","selected");
        }
    });
    //巴可查看或者修改页面
    function viewOrUpdateIReport(operationType){
        var title = "";
        if(operationType == "view"){
            title = "查看巡检报告";
        }else if(operationType == "update"){
            title = "修改巡检报告";
        }
        addOneTab(title,"zyInspectionReportController.do?goViewOrUpateIr&zyIpId=${zyIP.id }&operationType="+operationType);
    }
</script>
